from PIL import Image, ImageDraw

# 创建画布
img = Image.new('RGB', (600, 400), color='white')
draw = ImageDraw.Draw(img)

# 绘制圆形
circle_radius = 50
draw.ellipse([50, 50, 50 + 2 * circle_radius, 50 + 2 * circle_radius], outline='blue', width=2)
draw.text((60, 120), "Circle Area", fill="black")

# 绘制矩形
draw.rectangle([300, 50, 450, 150], outline='red', width=2)
draw.text((310, 80), "Rectangle Area", fill="black")

# 保存图像
img_path = "area_visualization.png"
img.save(img_path)
print(f"图形已保存为 {img_path}")